package com.Impl;

import com.dao.purchase_recordDao;
import com.entity.purchase_record;
import com.service.purchase_recordService;
import com.util.DataBaseUtil;

import java.sql.Connection;
import java.util.List;

public class purchase_recordServiceImpl implements purchase_recordService {

  @Override
  public List<purchase_record> findAll() {
    List<purchase_record> list = null;
    Connection con = null;
    try {
      con = DataBaseUtil.getCon();
      purchase_recordDao purchase_recordDao = new purchase_recordDaoImpl(con);
      list = purchase_recordDao.findAll();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DataBaseUtil.closeAll(con,null,null);
    }
    return list;
  }

  @Override
  public int getCount() {
    int count = 0;
    Connection con = null;
    try {
      con = DataBaseUtil.getCon();
      purchase_recordDao purchase_recordDao = new purchase_recordDaoImpl(con);
      count = purchase_recordDao.getCount();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      DataBaseUtil.closeAll(con,null,null);
    }
    return count;
  }
}
